< previous page page_26 next page >

Page 26
You can also include the two special items Spc(n) and Tab(n) in the output list. Spc(n) makes the Print method display n spaces. Keep in mind that, in most fonts, different characters have different widths, and the space character is often quite thin. Tab(n) makes the Print method move to the nth print zone.
The Print method begins displaying text with the upper-left corner of the text at the coordinates (CurrentX, CurrentY). A drawing object's CurrentX and CurrentY properties indicate the end point of the last drawing operation. When the Print statement finishes, it sets CurrentX to 0, and CurrentY so the next line of text appears below the current one.
The following code draws an X at position (1440, 720). It then sets (CurrentX, CurrentY) to this position and prints the text Line 1. After displaying Line 1, the Print statement sets CurrentX to 0 and CurrentY to position the next line of text under the first.
The program then displays Line 2. Because a comma comes next in the Print statement's output list, the Print method advances to the next print zone before displaying Zone 2. Another comma follows, so Print moves to the next print zone before printing Zone 3. Because this line ends in a semicolon, the Print command does not advance CurrentX and CurrentY. These values are left alone, so the next text appears immediately after Zone 3.
Finally, the code displays the text Line 3. Example program Print, shown in Figure 1.13, demonstrates this code.
e10a6a0a59f035e870d90cca05b85fce.gif
Const X = 1440
Const Y = 720

    AutoRedraw = True
    Line (X - 100, Y - 100)-Step(100, 100)
    Line (X + 100, Y - 100)-Step(-100, 100)

    CurrentX = X
    CurrentY = Y

    Print "Line 1"
    Print "Line 2", "Zone 2", "Zone 3";
    Print "Line 3"
0026-01.jpg
Figure 1.13
Example program Print displays text with the Print method.

 
< previous page page_26 next page >